#ifndef MAINWINDOW_H
#define MAINWINDOW_H

#include <QMainWindow>
#include <QJsonDocument>
#include <QJsonObject>
#include <QList>
#include <QSettings>
#include <QDir>

#include "../networkclient.h"
#include "../amplifierdata.h"

#define GUI_UPDATE_ALL          0
#define GUI_UPDATE_POWERMETER   1

//! The default size of the power meter buffer list
#define DEFAULT_POWERMETER_BUFFER_LIST_SIZE 20
//! The default IP address of the server
#define DEFAULT_NETWORK_SERVER_IP "192.168.1.116"
//! The default network port of the server
#define DEFAULT_NETWORK_SERVER_PORT "12345"
//! The default number of connect attempts the client tries
#define DEFAULT_NETWORK_CONNECT_ATTEMPTS 100
//! The default timeout between each connect attempt
#define DEFAULT_NETWORK_CONNECT_TIMEOUT  3000

namespace Ui {
class MainWindow;
}

class MainWindow : public QMainWindow
{
    Q_OBJECT
    
public:
    explicit MainWindow(QWidget *parent = 0);
    ~MainWindow();
    void updateGUI(quint8 type);
    void loadSettings(QSettings &settings);
private slots:
  void on_pushButtonConnect_clicked();
  void on_pushButtonDisconnect_clicked();
  void networkDataReady(QByteArray data);
  void networkError(const int &errorCode, const QString &errorString);
private:
    Ui::MainWindow *ui;
    NetworkClient *networkClient;
    AmplifierData *amplifierData;
    QList<quint16> listPowerMeterFWDPower;
    QList<quint16> listPowerMeterREFPower;
    QJsonObject jsonSettings;
    quint16 networkConnectAttemptCount;
};

#endif // MAINWINDOW_H
